<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>编辑</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
    <script type="text/javascript" th:src="@{/static/js/jquery-3.js}"></script>
    <script th:src="@{/static/layui/layui.js}" charset="utf-8"></script>

    <link rel="stylesheet" type="text/css" th:href="@{/static/kindeditor/themes/default/default.css}"/>
    <script charset="utf-8" th:src="@{/static/kindeditor/kindeditor-all.js}"></script>
    <script charset="utf-8" th:src="@{/static/kindeditor/lang/zh_CN.js}"></script>

    <style type="text/css">
        .layui-form-selectup dl{
            top:42px;
            bottom:unset;
        }
    </style>

    <script type="text/javascript">
        var basePath = "/";
        KindEditor.ready(function(K) {
            window.editor = K.create('#context', {
                width : '100%',
                height : '350px',
                allowFileManager : true,
                themeType : 'simple',
                readonlyMode : true,
                afterUpload: function(url) {
                    $("#inputId").val(url);
                },
                items:[
                    'undo', 'redo', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', '|',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor',
                    'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat',
                    '|', 'table',  'link', 'unlink','image'
                ],
            });
        });
    </script>

</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>修改文章</legend>
</fieldset>

<div class="layui-form-item">
    <label class="layui-form-label">id&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${articlePo.id}" type="text" name='id' id="id" readonly="readonly" class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">分类名称&nbsp;:</label>
    <div class="layui-input-block">
        <select name="sysSortname" id="sysSortname">
            <th:block th:each="userlist:${listes}">
                <option  th:selected="${userlist.name == articlePo.sortname}">[[${userlist.name}]]</option>
            </th:block>
        </select>

        <!-- <input th:value="${user.sortname}" type="text" name='attn' id="attn" lay-verify="required" lay-reqtext="用户昵称为必填项" placeholder="请输入用户昵称" autocomplete="off"  style="width:500px;"   class="layui-input" >-->
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">标题&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${articlePo.title}" type="text" name='title' id="title" readonly="readonly" class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">关键词&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${articlePo.keywords}" type="text" name='keywords' id="keywords" readonly="readonly"  class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">内容简介&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${articlePo.intro}" type="text" name='intro' id="intro" readonly="readonly" class="layui-input" >
    </div>
</div>


<div class="layui-form-item">
    <label class="layui-form-label">内容详情&nbsp;:</label>
    <div class="layui-input-block">
        <textarea id="context" readonly="true"  name="content" placeholder="我有更好的回答" style="width: 800px;">[[${articlePo.content}]]</textarea>
      <!--  <textarea type="text" name='content' id="content"  th:placeholder="${articlePo.content}">[[${articlePo.content}]]</textarea>-->
    </div>
</div>


<div class="layui-form-item">
    <label class="layui-form-label">推荐&nbsp;:</label>
    <div class="layui-input-block">
        <select name="nominate" id="nominate" lay-verify="required" style="width:500px; height: 38px;" class="layui-form-selectup">
            <option value="">请选择</option>
            <option th:selected="${articlePo.nominate == 0}" value="0">否</option>
            <option th:selected="${articlePo.nominate == 1}" value="1">是</option>
        </select>
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">置顶&nbsp;:</label>
    <div class="layui-input-block">
        <select name="top" id="top" lay-verify="required" style="width:500px; height: 38px;" class="layui-form-selectup">
            <option value="">请选择</option>
            <option th:selected="${articlePo.top == 0}" value="0">否</option>
            <option th:selected="${articlePo.top == 1}" value="1">是</option>
        </select>
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">更新时间&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${#dates.format(articlePo.updatedate,'yyyy-MM-dd')}" type="text" name='updatedate' id="updatedate" readonly="readonly" lay-verify="required" lay-reqtext="用户名为必填项" placeholder="请输入用户名" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">状态&nbsp;:</label>
    <div class="layui-input-block">
        <select name="state" id="state" lay-verify="required" style="width:500px; height: 38px;" class="layui-form-selectup">
            <option value="">请选择</option>
            <option th:selected="${articlePo.state == 0}" value="0">下架</option>
            <option th:selected="${articlePo.state == 1}" value="1">上架</option>
        </select>
    </div>
</div>



<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="editBtn">修改</button>
    </div>
</div>

<script>

    var basePath="/";

    layui.use(['form'],function () {
        var thisIndex = parent.layer.getFrameIndex(window.name);
        var form = layui.form;
        var parentLayer = parent.layer;
        form.on("submit(editBtn)",function () {
            var obj = {
                id:$("#id").val(),
                sortname:$("#sysSortname option:selected").val(),
                title: $("#title").val(),
                keywords:$("#keywords").val(),
                intro:$("#intro").val(),
                nominate:$("#nominate").val(),
                top:$("#top").val(),
                state: $("#state").val()


            };
            $.post(basePath+"article-updateArticle",obj,function (data) {
                if(data.success){
                    parentLayer.msg("修改成功",{
                        icon: 1,
                        time: 1000
                    });
                }else{
                    parentLayer.msg("修改失败",{
                        icon: 1,
                        time: 2000
                    });
                }
                parent.location.reload();
                parentLayer.close(thisIndex);
            },"json");

        })
    })

</script>

</body>
</html>